<!--conf
<sample in_favorites="true">
            <product version="2.0" edition="pro"/>
                     <modifications>
                            <modified date="070101"/>
                     </modifications>
               <sampledescription><![CDATA[dhtmlxMenu based context menu contains different items depending on properties of the tree node it was loaded for.]]></sampledescription></sample>
 --> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>Context menu based on item properties</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlx.css"/>
	<script src="../../../codebase/dhtmlx.js"></script>
</head>

<body>
	<h1>Context menu based on item properties</h1>
	
	
    <p>Right click on any tree node.<br>
	In the example below context menu is one for all items, but it is shown differently by using the hideButtons/showButtons menu methods (nodes without child items have more buttons in context menu).</p>     	
	<table>
		<tr>
			<td>
				<div id="treeboxbox_tree" style="width:260px; height:260px;background-color:#f5f5f5;border :1px solid Silver;"/>
			</td>
			<td valign="top">
			</td>
		</tr>
		<tr>
			<td></td>
		</tr>
	</table>
	<div id="aler"></div>
<br>

<script>
			
	function onButtonClick(menuitemId,type){
	                var id = tree.contextID;
                	tree.setItemColor(id,menuitemId.split("_")[1]);
	}

	menu = new dhtmlXMenuObject();
	menu.setIconsPath("../common/images/menu/");
	menu.renderAsContextMenu();
	menu.attachEvent("onClick",onButtonClick);
	menu.loadStruct("../common/_context.xml");
	
	tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);

	
	tree.setSkin('dhx_skyblue');
	tree.setImagePath("../../../codebase/imgs/dhxtree_skyblue/");
	tree.enableDragAndDrop(true);			
	tree.enableContextMenu(menu);

tree.attachEvent("onBeforeContextMenu",function(itemId){
	if (tree.hasChildren(itemId) > 0){
		menu.hideItem('outher');
	} else {
		menu.showItem('outher');
	}
	return true
})
	tree.loadXML("../common/tree.xml")
			
			
	</script>
<br><br>

</body>
</html>
